package com.hrsystem.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.api.R;
import com.hrsystem.entity.JobTitle;
import com.hrsystem.entity.OrgThird;
import com.hrsystem.lang.Result;
import com.hrsystem.mapper.JobTitleMapper;
import com.hrsystem.service.JobTitleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Luo
 * @since 2021-12-23
 */
@RestController
public class JobTitleController {

    @Resource
    JobTitleMapper jobTitleMapper;

    @Autowired
    JobTitleService jobTitleService;

    @Transactional
    @GetMapping("/selectJobTitle/{id}")
    public Result selectjobTitleList(@PathVariable(name = "id") Long id) {
        QueryWrapper<JobTitle> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("nJob_id",id);
        List<JobTitle> jobTitleList = jobTitleMapper.selectList(queryWrapper);
        return Result.success(jobTitleList);
    }

    @Transactional
    @PostMapping("/AddJobTitle")
    public Result addJobTitle(@RequestBody JobTitle jobTitle){
        jobTitleService.saveOrUpdate(jobTitle);
        return Result.success(null);
    }

}
